package main

import (
	"fmt"
	"gitee.com/trackertrader/rpcx/log"
	"github.com/BurntSushi/toml"
	"github.com/urfave/cli/v2"
	"os"
)

// 版本号
const BuildVersion = "0.1.0"

func main() {
	if "" == os.Getenv("QUOTERECORDER_HOME") {
		fmt.Println("请配置QUOTERECORDER_HOME环境变量")
		os.Exit(0)
	}
	if _, err := toml.DecodeFile(os.Getenv("QUOTERECORDER_HOME")+"/conf/config.toml", &Conf); err != nil {
		log.Error(err)
		os.Exit(0)
	}

	app := &cli.App{
		Name:                 "quote recorder",
		Usage:                "行情报价记录器",
		Version:              BuildVersion,
		EnableBashCompletion: true,
		Commands: []*cli.Command{
			QuantrecorderCmd,
			QuantrecorderStopCmd,
		},
	}
	app.Setup()
	err := app.Run(os.Args)
	if err != nil {
		log.Error(err)
	}
}
